/*
 * test.c
 *
 *  Created on: 28.12.2012
 *      Author: kir
 */

#include "hpi.h"
#include <std.h>
#include <log.h>
#include <hwi.h>
#include <sem.h>
#include <stdio.h>

#include <C64.h>
#include "dsp_bios_testcfg.h"

#include "exch.h"

#pragma DATA_SECTION(g_hpi_exch, ".HPI_EXCH");
hpi_exch_t g_hpi_exch;

Void test_task(Arg arg)
{
  LOG_printf(&trace, "test task started");
  printf("address of rd_st %x\n", &g_hpi_exch.rd_st);

  g_hpi_exch.rd_st = 1 << eRD_STATUS;
  hpi_set_host_int();
  while(1)
    {
      if (SEM_pend(&SEMTEST, SYS_FOREVER))
        {
          LOG_printf(&trace, "0x%x", g_hpi_exch.wr_st);
          hpi_set_host_int();
        }
    }
}

Void hpi_handler(void)
{
  LOG_printf(&trace, "hpi_handler");
  SEM_post(&SEMTEST);
  hpi_set_dsp_int();
}
